#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

int main()
{
    int n, a[100001] = { 0 }, b[100001] = { 0 }, g[100001] = { 0 }, k[100001] = { 0 };
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i]>>b[i]>>g[i]>>k[i];
    }
    int x, y;
   cin>>x>>y;
    for (int i = n; i >= 1; i--)
    {
        if (x >= a[i] && x <= a[i] + g[i] && y >= b[i] && y <= b[i] + k[i])
        {
            cout << i;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}